const path = require('path');

const htmlWebpackPlugin = require('html-webpack-plugin');

const VueLoaderPlugin = require('./node_modules/vue-loader/lib/plugin.js');

module.exports ={
    entry : path.join(__dirname,'./src/main.js'),
    output:
        {
            path : path.join(__dirname,'./dist'),
            filename :'bundle.js'
        },
    plugins:[
        new htmlWebpackPlugin({
            template:path.join(__dirname,'./src/index.html'),
            filename: "index.html"
        }),
        new VueLoaderPlugin({})
    ],
    module:{//配置所有第三方loader模块的
        rules:[
            {test:/\.css$/,use:['style-loader','css-loader']},
            {test:/\.scss$/,use:['style-loader','css-loader','sass-loader']},
            {test:/\.less$/,use:['style-loader','css-loader','less-loader']},
            {test:/\.jpg|png|bmp|gif|jpeg$/,use:'url-loader?limit=28221&name=[hash:8]-[name].[ext]'},
            //当图片大小大于28221byte时，则不会将图片名称转化为base64格式的字符串。name键指定的是图片原名称前加8位的哈希值【哈希值最大是32位】，防止重名
            {test:/\.ttf|eot|svg|woff|woff2$/i,use:'file-loader'},
            {
                test:/\.js$/,
                use:{
                    loader: 'babel-loader',
                    options: {
                      presets: ['@babel/preset-env'],
                      plugins: ['@babel/plugin-transform-runtime','@babel/plugin-proposal-class-properties']
                    }
                },
                exclude:/node_modules/
            },
            { test:/\.vue$/,use:"vue-loader"}
        ]
    },
    resolve:{
        alias:{//alias是【别名】的意思
            // "vue$":'vue/dist/vue.js'
        }
    }

}